package com.lyf.scm.job.task;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.lyf.scm.common.constants.CommonConstants;
import com.lyf.scm.job.config.AbstractSimpleJob;
import com.lyf.scm.job.remote.facade.UpConfirmStatusFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * description:
 *          更新直营预测计划确认状态Job
 * @author: haodong
 * @data: 2020/9/3 10:15
 */
@Slf4j
@Component
public class UpFourConfirmStatusJob extends AbstractSimpleJob {

    @Value("${elastic.job.UpFourConfirmStatusJob.jobName}")
    private String jobName;
    @Value("${elastic.job.UpFourConfirmStatusJob.cron}")
    private String cron;
    @Value("${elastic.job.UpFourConfirmStatusJob.shardingTotalCount}")
    private Integer shardingTotalCount;
    @Value("${elastic.job.UpFourConfirmStatusJob.shardingItemParameters}")
    private String shardingItemParameters;
    @Value("${elastic.job.UpFourConfirmStatusJob.failover}")
    private Boolean failover;
    @Value("${elastic.job.UpFourConfirmStatusJob.desc}")
    private String desc;

    @Resource
    private UpConfirmStatusFacade upConfirmStatusFacade;

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("开始更新四级确认状态。。。");
        upConfirmStatusFacade.upConfirmStatus(CommonConstants.AREA_LEVEL_FOUR);
        log.info("更新四级确认状态结束。。。");
    }

    @Override
    public void run(String... args) throws Exception{
        // spring 启动完成后初始化job
        registerSimpleJob(jobName, cron, shardingTotalCount, shardingItemParameters, failover, desc);
    }
}
